import math

if __name__ == '__main__':
    order = 1000000
    src = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    num = []
    for i in range(9, 0, -1):
        num.append((order // math.factorial(i)) + (-1 if order % math.factorial(i) == 0 else 0))
        order %= math.factorial(i)
    res = ''
    for i in num:
        res += str(src[i])
        src.remove(src[i])
    print(res + str(src[0]))
